<?php
/**
 * 商场特卖
 * @author Ice <iceinto@mallog.com.cn>
 */
class DiscountAction extends BaseAction
{
    function _initialize()
    {
        $this->assign('nav', 5);
        parent::_initialize();
    }

    public function index()
    {
        $dis = $this->getMallDis();
        $this->assign('dis', $dis);
        $titles = array('特卖汇总');
        $this->seoSet($titles, $titles);
        $this->display();
    }

    /**
     * 热卖详细
     * @author Ice <iceinto@mallog.com.cn>
     */
    public function detail()
    {
        $itemid = intval($this->_get('id'));
        if (!$itemid) {
            $this->error('热卖标示不对！');
        }
        //获取热卖详细
        $MallDiscountModel = D('MallDiscount');
        $dis = $MallDiscountModel->find($itemid);
        if (empty($dis)) {
            $this->error('热卖不存在！');
        }
        //获取品牌宣传图
        $address = $MallDiscountModel->getAdMFB($dis['mid'], $dis['fid'], $dis['bid']);
        //获取品牌信息
        if (!empty($address['brand'])) {
            $brand = $address['brand'];
            $BrandModel = D('Brand');
            $brand = $BrandModel->find($brand['id']);
            //品牌详细信息 获取图片
            $brand['image_url'] = $BrandModel->getBrandImage($brand['image']);
            //获取关注
            $brand['att_count'] = D('BrandAttention')->getAttCount($brand['id']);
            //获取展示图
            $brand['slide'] = D('Slide')->getBrandOne($brand['id']);
            //获取同类品牌推荐
            $brand['similar'] = $this->getSimilarBrandById($brand['id']);
            //当前用户是否关注
            $uid = getLoginUserInfo();
            if ($uid) {
                D('BrandAttention')->checkUserIsAttrBrand($uid, $brand);
            }
            $this->assign('brand', $brand);
        }
        $titles = array('特卖汇总', $address['mall']['name'], $address['floor']['name'], $address['floor']['sain'], $brand['ename'], $brand['name']);
        $this->seoSet($titles, $titles);
        $this->assign('dis', $dis);
        $this->assign('mall', $address['mall']);
        $this->assign('floor', $address['floor']);
        $this->display();
    }
}

?>